﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace GameSchool.Models
{
    #region Classes

    //Eric
    public class Achievement
    {
        public int achievementID { get; set; } //primary key
        public int? teacherID { get; set; } //foreign key
        public string title { get; set; }
        public string description { get; set; }
        public string type { get; set; }

        //Relationships
        public virtual Teacher teacher { get; set; }
        public virtual ICollection<Course> courses { get; set; }
        public virtual ICollection<Student> students { get; set; }

        //Combined tables
        public virtual ICollection<CourseAchievement> courseAchievements { get; set; }
        public virtual ICollection<AchievementCourseStudent> achievementCourseStudents { get; set; }
    }

    //Eric
    public class Like
    {
        public int likeID { get; set; } //primary key
        public int commentID { get; set; } //foreign key
        public int studentID { get; set; } //foreign key

        //Relationships
        public virtual Comment comment { get; set; }
        public virtual Student student { get; set; }
    }

    // eiki
    public class Student
    {
        public int studentID { get; set; } // primary key
        public string name { get; set; }
        public string email { get; set; }
        public int kennitala { get; set; }
        public string address { get; set; }
        public int zip { get; set; }
        public int phone { get; set; }
        public string userName { get; set; }
        public Guid userNameID { get; set; }

        //Relationships
        public virtual ICollection<Achievement> achievements { get; set; }
        public virtual ICollection<Course> courses { get; set; }
        public virtual ICollection<Comment> comments { get; set; }
        public virtual ICollection<Assignment> assignments { get; set; }
        public virtual ICollection<Like> likes { get; set; }
        public virtual ICollection<Exam> exams { get; set; }
        public virtual ICollection<Level> levels { get; set; }
        public virtual ICollection<Lecture> lectures { get; set; }

        //combined tables
        public virtual ICollection<StudentCourse> studentCourses { get; set; }
        public virtual ICollection<StudentAssignment> studentAssignments { get; set; }
        public virtual ICollection<StudentExam> studentExams { get; set; }
        public virtual ICollection<StudentLecture> studentLectures { get; set; }
        public virtual ICollection<StudentLevel> studentLevels { get; set; }
        public virtual ICollection<AchievementCourseStudent> achievementCourseStudents { get; set; }
    }

    //Eric
    public class Comment
    {
        public int commentID { get; set; } //primary key
        public int? teacherID { get; set; } //foreign key
        public int? studentID { get; set; } //foreign key
        public int lectureID { get; set; } //foreign key
        public string commentBody { get; set; }
        public bool approved { get; set; }
        public DateTime CommentTime {get; set;}
        public string userName { get; set; }

        //Relationships
        public virtual Teacher teacher { get; set; }
        public virtual Student student { get; set; }
        public virtual Lecture lecture { get; set; }
        public virtual ICollection<Like> likes { get; set; }
    }

    //doddi
    public class Teacher
    {
        public int teacherID { get; set; } //primary key
		public string name { get; set; }
        public string email { get; set; }
        public int kennitala { get; set; }
        public string address { get; set; }
        public int zip { get; set; }
        public int phone { get; set; }
        public bool selected { get; set; } // need this for the create course view -eiki
        public string userName { get; set; }
        public Guid userNameID { get; set; }

        //Relationships
        public virtual ICollection<Course> courses { get; set; }
        public virtual ICollection<Achievement> achievements { get; set; }
        public virtual ICollection<Comment> comments { get; set; }

        //Combined tables
        public virtual ICollection<TeacherCourse> teacherCourses { get; set; }
    }

    //doddi
    public class Level
    {
        public int levelID { get; set; } //primary key
        public int courseID { get; set; } //foreign key
        public string title { get; set; }
        public string description { get; set; }
        public int number { get; set; }
        public int intLevelXP { get; set; }
        public double doubleLevelXP { get; set; }

        //Relationships
        public virtual Course course { get; set; }
        public virtual ICollection<Student> students { get; set; }
        public virtual ICollection<Lecture> lectures { get; set; }
        public virtual ICollection<Assignment> assignments { get; set; }
        public virtual ICollection<Exam> exams { get; set; }

        //Combined tables
        public virtual ICollection<StudentLevel> studentLevels { get; set; }
    }

    //doddi
    public class Lecture
    {
        public int lectureID { get; set; } //primary key
        public int levelID { get; set; } //foreign key
        public string title { get; set; }
        public string description { get; set; }
        public string lectureFile { get; set; } //need to figure out how to edit get file
        public int likeAmountToGainXP { get; set; }
        public bool allowApproval { get; set; }
        public int approvalXPAmount { get; set; }
        public int likeXPAmount { get; set; }
        public double lectureXP { get; set; }

        //Relationships
        public virtual Level level { get; set; }
        public virtual ICollection<Student> students { get; set; }
        public virtual ICollection<Comment> comments { get; set; }

        //Combined tables
        public virtual ICollection<StudentLecture> studentLectures { get; set; }
    }
    //doddi
    public class Assignment
    {
        public int assignmentID { get; set; } //primary key
        public int levelID { get; set; } //foreign key
        public string title { get; set; }
        public string description { get; set; }
        public string file { get; set; } //EDIT
        public int timeLimit { get; set; }
        public double assignmentXP { get; set; }

        //Relationships
        public virtual Level level { get; set; }
        public virtual ICollection<Student> students { get; set; }

        //Combined tables
        public virtual ICollection<StudentAssignment> studentAssignments { get; set; }
    }
    //doddi
    public class Question
    {
        public int questionID { get; set; } //primary key
        public int examID { get; set; } //foreign key
        public string question { get; set; }
        public int questionXP { get; set; }

        //Relationships
        public virtual Exam exam { get; set; }
        public virtual ICollection<Answer> answers { get; set; }
    }

    // eiki
    public class Course
    {
        public int courseID { get; set; } // primary key
        public string title { get; set; }
        public string description { get; set; }
        public int courseXP { get; set; }
        public int numStudents { get; set; }
        public int numTeachers { get; set; }

        //Relationships
        public virtual ICollection<Student> students { get; set; }
        public virtual ICollection<Teacher> teachers { get; set; }
        public virtual ICollection<Achievement> achievements { get; set; }
        public virtual ICollection<Level> levels { get; set; }

        //Combined tables
        public virtual ICollection<TeacherCourse> teacherCourses { get; set; }
        public virtual ICollection<StudentCourse> studentCourses { get; set; }
        public virtual ICollection<CourseAchievement> courseAchievements { get; set; }
        public virtual ICollection<AchievementCourseStudent> achievementCourseStudents { get; set; }
    }


    // eiki
    public class Exam
    {
        public int examID { get; set; } // primary key
        public int levelID { get; set; } //foreign key
        public string title { get; set; }
        public string description { get; set; }
        public int timeLimit { get; set; }
        public double examXP { get; set; }
        //public string examInput { get; set; }

        //Relationships
        public virtual Level level { get; set; }
        public virtual ICollection<Student> students { get; set; }
        public virtual ICollection<Question> questions { get; set; }

        //Combined tables
        public virtual ICollection<StudentExam> studentExams { get; set; }
    }

    // eiki
    public class Answer
    {
        public int answerID { get; set; } // primary key
        public int questionID { get; set; } //foreign key
        public bool correct { get; set; }
        public string answer { get; set; }

        //Relationships
        public virtual Question question { get; set; }
    }

    #endregion

    #region Relationship classes

    public class TeacherCourse
    {
        public virtual int teacherID { get; set; }
        public virtual int courseID { get; set; }
        public virtual Teacher teacher { get; set; }
        public virtual Course course { get; set; }
    }

    public class StudentCourse
    {
        public virtual int studentID { get; set; }
        public virtual int courseID { get; set; }
        public virtual Student student { get; set; }
        public virtual Course course { get; set; }
        public virtual int studentXP { get; set; } //Additional info
    }

    public class StudentAssignment : StudentMasterViewModel
    {
        public virtual int studentID { get; set; }
        public virtual int assignmentID { get; set; }
        public virtual Student student { get; set; }
        public virtual Assignment assignment { get; set; }
        public virtual byte[] binaryFile { get; set; }
        public virtual DateTime? handedInTime { get; set; }
        public IEnumerable<Level> levels { get; set; }
        public IEnumerable<Level> levelsTemp { get; set; }
        public List<Assignment> AssignmentList { get; set; }
        public int courseID { get; set; }
        public class deadlinesListItem
        {
            public string courseName { get; set; }
            public string taskType { get; set; }
            public string level { get; set; }
            public int daysLeft { get; set; }
        }
        public List<deadlinesListItem> deadlines { get; set; }


    }

    public class StudentExam
    {
        public virtual int studentID { get; set; }
        public virtual int examID { get; set; }
        public virtual Student student { get; set; }
        public virtual Exam exam { get; set; }
    }

    public class StudentLecture
    {
        public virtual int studentID { get; set; }
        public virtual int lectureID { get; set; }
        public virtual Student student { get; set; }
        public virtual Lecture lecture { get; set; }
    }

    public class StudentLevel
    {
        public virtual int studentID { get; set; }
        public virtual int levelID { get; set; }
        public virtual Student student { get; set; }
        public virtual Level level { get; set; }
        public virtual bool unlocked { get; set; } //Additional info
    }

    public class CourseAchievement
    {
        public virtual int courseID { get; set; }
        public virtual int achievementID { get; set; }
        public virtual Course course { get; set; }
        public virtual Achievement achievement { get; set; }
    }

    public class AchievementCourseStudent
    {
        public virtual int achievementID { get; set; }
        public virtual int courseID { get; set; }
        public virtual int studentID { get; set; }
        public virtual Achievement achievement { get; set; }
        public virtual Course course { get; set; }
        public virtual Student student { get; set; }
    }
    #endregion
}

    //This is to connect the account info with our databases























